package com.lagou.sqlSession;

import com.lagou.config.XMLConfigBuilder;
import com.lagou.pojo.Configuration;

import java.io.InputStream;

/**
 * @author: lcz
 * @date: Created in 13:54 2020/9/25
 * @description:
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory builder(InputStream inputStream) throws Exception {
        //解析配置文件，封装configuration
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.pareConfig(inputStream);
        //创建sqlSessionFactory
        SqlSessionFactory sqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        return sqlSessionFactory;
    }
}
